#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <cassert>
using namespace std;
#define forn(i,n) for(int i=0;i<int(n);++i)
#define dforn(i,n) for(int i=(n)-1;i>=0;--i)
#define forsn(i,s,n) for(int i=s;i<int(n);++i)
#define forall(it,X) for(typeof(X.begin()) it = X.begin(); it != X.end(); ++it)

int main() {
	ifstream in("input.txt");
	double error=0.0,a,b;
	int n;
	cin >> a >> a >> a >> a; //dummy reads from original input
	in >> n;
	forn(i,n*n) {
		in >> a; cin >> b; error+=(a-b)*(a-b);
	}
	cout.precision(20);
	cout << error/(n*n) << endl;
    return 0;
}
